//
//  ViewController.m
//  测试Demo
//
//  Created by L.Hawk on 2016/11/21.
//  Copyright © 2016年 itheima. All rights reserved.
//

#import "LBMeMessageSystemViewController.h"
#import "meMessageSystemCell.h"
#import "meMessageSystemModel.h"
#import "YYModel.h"
#import "Masonry.h"

static NSString * cellID = @"cellID";
@interface LBMeMessageSystemViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,copy)NSArray *modelArr;

@end

@implementation LBMeMessageSystemViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor lightGrayColor];
    
    [self setupUI];
    // Do any additional setup after loading the view, typically from a nib.
}


-(void)setupUI{
    UITableView *meMessageView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    [self.view addSubview:meMessageView];
    meMessageView.dataSource = self;
    meMessageView.delegate = self;
    
    [meMessageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.view);
        make.top.equalTo(self.view).offset(64);
    }];
    
    
    //创建一个数组来获取plist的值
    NSString *path = [[NSBundle mainBundle]pathForResource:@"meMessageSystem.plist" ofType:nil];
    NSArray *arr = [NSArray arrayWithContentsOfFile:path];
    
    //model接收数组中的值
    NSArray<meMessageSystemModel *> *modelArr = [NSArray yy_modelArrayWithClass:[meMessageSystemModel class] json:arr];
    _modelArr = modelArr;
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    meMessageSystemCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(cell ==nil){
        cell = [[meMessageSystemCell alloc]init];
    }
    
    //正文
    meMessageSystemModel *model = [[meMessageSystemModel alloc]init];
    model = _modelArr[indexPath.section];
    cell.title.text = model.title;
    cell.label.text = model.label;
    cell.content.text = model.content;
    
    
    return cell;
}


//设定tableView的组间距
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 2;
}

//设定tableView的row高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 120.0;
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
